package com.example.server.service;


import com.example.server.domain.Dormchange;
import com.example.server.domain.Dormchange;
import com.example.server.mapper.DormchangeMapper;
import com.example.server.mapper.DormchangeMapper;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class DormchangeService {

    private final DormchangeMapper dormchangeMapper;

    public DormchangeService(DormchangeMapper dormchangeMapper) {
        this.dormchangeMapper = dormchangeMapper;
    }
    public void createDormchange(Dormchange dormchange) {
        dormchangeMapper.insert(dormchange);
    }

    public void deleteDormchange(Long id) {
        dormchangeMapper.deleteByPrimaryKey(id);
    }

    public Dormchange getDormchangeById(Long id) {
        return dormchangeMapper.selectByPrimaryKey(id)   ;
    }

    public void updateDormchange(Dormchange dormchange) {
        dormchangeMapper.updateByPrimaryKey(dormchange);

    }

    public List<Dormchange> getAllDormchange() {


        return dormchangeMapper.selectAll();
    }

    public void approvePass(Long id) {
        dormchangeMapper.approvePass(id);
    }

    public void approveReject(Long id) {

        dormchangeMapper.approveReject(id);
    }

    public List<Dormchange> querylike(String sname) {
        return dormchangeMapper.querylike(sname);
    }
}
